//
//  CALayer+Margin.m
//  NineteenBook
//
//  Created by xhkj on 2021/8/2.
//  Copyright © 2021 58阅读. All rights reserved.
//

#import "CALayer+Margin.h"

@implementation CALayer (Margin)

- (CGFloat)kr_left{
    return self.frame.origin.x;
}

- (void)setKr_left:(CGFloat)left{
    CGRect frame = self.frame;
    frame.origin.x = left;
    self.frame = frame;
}

- (CGFloat)kr_top {
    return self.frame.origin.y;
}

- (void)setKr_top:(CGFloat)y {
    CGRect frame = self.frame;
    frame.origin.y = y;
    self.frame = frame;
}

- (CGFloat)kr_right {
    return self.frame.origin.x + self.frame.size.width;
}

- (void)setKr_right:(CGFloat)right {
    CGRect frame = self.frame;
    frame.origin.x = right - frame.size.width;
    self.frame = frame;
}

- (CGFloat)kr_bottom {
    return self.frame.origin.y + self.frame.size.height;
}

- (void)setKr_bottom:(CGFloat)bottom {
    CGRect frame = self.frame;
    frame.origin.y = bottom - frame.size.height;
    self.frame = frame;
}

- (CGFloat)kr_width {
    return self.frame.size.width;
}

- (void)setKr_width:(CGFloat)width {
    CGRect frame = self.frame;
    frame.size.width = width;
    self.frame = frame;
}

- (CGFloat)kr_height {
    return self.frame.size.height;
}

- (void)setKr_height:(CGFloat)height {
    CGRect frame = self.frame;
    frame.size.height = height;
    self.frame = frame;
}

- (CGFloat)kr_positionX {
    return self.position.x;
}

- (void)setKr_positionX:(CGFloat)positionX {
    self.position = CGPointMake(positionX, self.position.y);
}

- (CGFloat)kr_positionY {
    return self.position.y;
}

- (void)setKr_positionY:(CGFloat)positionY {
    self.position = CGPointMake(self.position.x, positionY);
}

- (CGPoint)kr_origin {
    return self.frame.origin;
}

- (void)setKr_origin:(CGPoint)origin {
    CGRect frame = self.frame;
    frame.origin = origin;
    self.frame = frame;
}

- (CGSize)kr_size {
    return self.frame.size;
}

- (void)setKr_size:(CGSize)size {
    CGRect frame = self.frame;
    frame.size = size;
    self.frame = frame;
}


@end
